#include <bits/stdc++.h>
using namespace std;

// 两个人相遇转身，相当于交换灵魂后继续走
const int R = 5e3 + 10;
int p[R];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int len, n, i, mid, bia, minTime = 0, maxTime;
	cin >> len >> n;
	if (!n)
	{
		cout << "0 0";
		return 0;
	}
	for (i = 1; i <= n; ++i)
	{
		cin >> p[i];
	}
	sort(p + 1, p + n + 1);
	for (i = 1; i <= n; ++i)
	{
		minTime = max(minTime, min(p[i], len - p[i] + 1));
	}
	maxTime = max(p[n], len - p[1] + 1);
	cout << minTime << ' ' << maxTime;
	return 0;
}
